home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 9
/
FM Towns Free Software Collection 9.iso
/
t_os
/
tool
/
otohime
/
src
/
otfile.c
< prev
next >
Wrap
Text File
|
1994-11-16
|
10KB
|
440 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winb.h>
#include <te.h>
#include <fntb.h>
#include <gui.h>
#include <file_dlg.h>
#include <egb.h>
#include <mos.h>
#include <snd.h>
#include "otohime.h"
#include "otolib.h"
/* mix */
int mixDialogId = -1 ;
int mixMesId[30] = -1 ;
int mixSubDialogId = -1 ;
int mixDiskVolumeId = -1 ;
int mixMemoryVolumeId = -1 ;
int mixDiskNumId = -1 ;
int mixMemoryNumId = -1 ;
int mixOkBtnId = -1 ;
int mixCanBtnId = -1 ;
/* rec */
int recDialogId = -1 ;
int recMesId[11] = -1 ;
int recOkBtnId = -1 ;
int recPlayBtnId = -1 ;
int recUndoBtnId = -1 ;
int recCanBtnId = -1 ;
int recSubDialogId = -1 ;
int recLineVolumeId = -1 ;
int recCdVolumeId = -1 ;
int recMicVolumeId = -1 ;
int recLineNumId = -1 ;
int recCdNumId = -1 ;
int recMicNumId = -1 ;
int recTimeNumId = -1 ;
int recRateNumId = -1 ;
/* MIX */
static int mixFlag ;
int sndMix()
{
int var, min, max, delta, ptColumn ;
MMI_SendMessage( mixDialogId, MM_ATTACH, 1, MMI_GetBaseObj() ) ;
MMI_SendMessage( mixDialogId, MM_SHOW, 0 ) ; /* 全体を見せる */
MMI_ExecSystem() ; /* Dialog表示へ・・・イベントループ */
MMI_SendMessage( mixDialogId, MM_ERASE, 0 ) ;
MMI_SendMessage( mixDialogId, MM_DETACH, 0 ) ;
if( mixFlag == TRUE )
{
char para[64] ;
char work[512] ;
MMI_SendMessage( mixMemoryNumId, MM_GETNUMBOX, 5,
&var, &min, &max, &delta, &ptColumn ) ;
DWORD( para + 0 ) = var * 256 / 100 ;
MMI_SendMessage( mixDiskNumId, MM_GETNUMBOX, 5,
&var, &min, &max, &delta, &ptColumn ) ;
DWORD( para + 4 ) = var * 256 / 100 ;
DWORD( para + 8 ) = sndBufSize ;
sndMixTrans( sndBuf2, sndBuf1, para, work ) ;
}
else
{
unDo() ;
}
return NOERR ;
}
/* 各種ボリューム設定 */
int mixVolumeSet(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
int var, min, max, len, page ;
int var2, min2, max2, delta2, ptColumn2 ;
if( kobj == mixDiskVolumeId ) /* ディスクmixVol. */
{
MMI_SendMessage( kobj, MM_GETSCROLL, 5,
&var, &min, &max, &len, &page ) ;
MMI_SendMessage( mixDiskNumId, MM_GETNUMBOX, 5,
&var2, &min2, &max2, &delta2, &ptColumn2 ) ;
MMI_SendMessage( mixDiskNumId, MM_SETNUMBOX, 5,
var, min2, max2, delta2, ptColumn2 ) ;
MMI_SendMessage( mixDiskNumId, MM_SHOW, 0 ) ;
}
if( kobj == mixDiskNumId ) /* ディスクmixNum. */
{
MMI_SendMessage( kobj, MM_GETNUMBOX, 5,
&var2, &min2, &max2, &delta2, &ptColumn2 ) ;
MMI_SendMessage( mixDiskVolumeId, MM_GETSCROLL, 5,
&var, &min, &max, &len, &page ) ;
MMI_SendMessage( mixDiskVolumeId, MM_SETSCROLL, 5,
var2, min, max, len, page ) ;
MMI_SendMessage( mixDiskVolumeId, MM_SHOW, 0 ) ;
}
if( kobj == mixMemoryVolumeId ) /* メモリmixVol. */
{
MMI_SendMessage( kobj, MM_GETSCROLL, 5,
&var, &min, &max, &len, &page ) ;
MMI_SendMessage( mixMemoryNumId, MM_GETNUMBOX, 5,
&var2, &min2, &max2, &delta2, &ptColumn2 ) ;
MMI_SendMessage( mixMemoryNumId, MM_SETNUMBOX, 5,
var, min2, max2, delta2, ptColumn2 ) ;
MMI_SendMessage( mixMemoryNumId, MM_SHOW, 0 ) ;
}
if( kobj == mixMemoryNumId ) /* メモリmixNum. */
{
MMI_SendMessage( kobj, MM_GETNUMBOX, 5,
&var2, &min2, &max2, &delta2, &ptColumn2 ) ;
MMI_SendMessage( mixMemoryVolumeId, MM_GETSCROLL, 5,
&var, &min, &max, &len, &page ) ;
MMI_SendMessage( mixMemoryVolumeId, MM_SETSCROLL, 5,
var2, min, max, len, page ) ;
MMI_SendMessage( mixMemoryVolumeId, MM_SHOW, 0 ) ;
}
return NOERR ;
}
/* 実行, 取消 */
int mixOkchk(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
if( kobj == mixOkBtnId )
mixFlag = TRUE ;
else
mixFlag = FALSE ;
MMI_SetHaltFlag( TRUE ) ;
return NOERR ;
}
/* REC */
int sndRec()
{
int var, min, max, delta, ptColumn ;
// MTL_resetAtrObj( recOkBtnId, ~MS_EVMOSOFFL40 ) ; /* 放したときのexe解除 */
// MTL_setAtrObj( recOkBtnId, MS_EVMOSONL40 ) ; /* 押したときにexe */
// MTL_setAtrObj( recPlayBtnId, (MS_EVMOSONL40 | MS_EVDRAGOUTL40) ) ;
// /* 押したとき,外れたときにもexe */
/* ボリュームセット */
SND_elevol_mute( 0x00000000 ) ;
MMI_SendMessage( recLineNumId, MM_GETNUMBOX, 5, /* Line Volune set */
&var, &min, &max, &delta, &ptColumn ) ;
if( var )
SND_elevol_set( 0, var, var ) ;
MMI_SendMessage( recCdNumId, MM_GETNUMBOX, 5, /* CD Volune set */
&var, &min, &max, &delta, &ptColumn ) ;
if( var )
SND_elevol_set( 1, var, var ) ;
MMI_SendMessage( recMicNumId, MM_GETNUMBOX, 5, /* Mic Volune set */
&var, &min, &max, &delta, &ptColumn ) ;
if( var )
SND_elevol_set( 2, var, var ) ;
MMI_SendMessage( recDialogId, MM_ATTACH, 1, MMI_GetBaseObj() ) ;
MMI_SendMessage( recDialogId, MM_SHOW, 0 ) ; /* 全体を見せる */
MMI_ExecSystem() ; /* Dialog表示へ・・・イベントループ */
MMI_SendMessage( recDialogId, MM_ERASE, 0 ) ;
MMI_SendMessage( recDialogId, MM_DETACH, 0 ) ;
SND_elevol_mute( 0x00000000 ) ;
return NOERR ;
}
/* 実行 */
int recOkchk(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
if( trigger & MS_EVMOSONL40 )
{
setMsgColor( recMesId[0], EXE_COLOR ) ;
MG_mosDisp( 2 ) ;
sndRecExec() ;
MG_mosDisp( 3 ) ;
setMsgColor( recMesId[0], MOJI_COLOR ) ;
MMI_FlushEvnt() ; /* イベントをフラッシュ */
}
return NOERR ;
}
/* 録音実行ルーチン */
int sndRecExec()
{
SNDHEAD *head ;
int i, var1, var2, min, max, delta, ptColumn ;
MMI_SendMessage( recRateNumId, MM_GETNUMBOX, 5, /* サンプリングレート抽出 */
&var1, &min, &max, &delta, &ptColumn ) ;
MMI_SendMessage( recTimeNumId, MM_GETNUMBOX, 5, /* 録音時間抽出 */
&var2, &min, &max, &delta, &ptColumn ) ;
interrupt_disable() ; /* 高音質のためインタラプトを掛ける */
SND_pcm_rec( var1, sndBuf1+32, var1 * var2 / 10, 0 );
interrupt_enable() ;
head = (SNDHEAD *)sndBuf1 ; /* ヘッダ書き込み */
for( i=0 ; i<8 ; i++ )
head->name[i] = '\0' ;
head->id = 0 ;
head->length = var1 * var2 / 10 ;
head->looppoint = 0 ;
head->looplength = 0 ;
head->freq = var1 * 0x62 / 1000 ;
head->adjust = 0 ;
head->note = 60 ;
head->reserve1 = 0 ;
head->reserve2 = 0 ;
return NOERR ;
}
/* 取消 */
int recCanchk(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
MMI_SetHaltFlag( TRUE ) ;
return NOERR ;
}
/* 再生 */
int recPlay(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
static int s = 0 ;
static int lev = 0 ;
if( trigger & MS_EVMOSONL40 ) /* マウスONで消音 */
{
if( lev == 0 )
{
lev = 1 ;
SND_get_elevol_mute( &s ) ;
SND_elevol_mute( 0 ) ;
}
}
if( trigger & MS_EVDRAGOUTL40 ) /* オブジェクト外で音の復帰 */
{
if( lev == 1 )
{
lev = 0 ;
SND_elevol_mute( s ) ;
}
}
if( trigger & MS_EVMOSOFFL40 ) /* マウスOFFで再生開始 */
{
if( lev == 0 )
{
lev = 1 ;
SND_get_elevol_mute( &s ) ;
SND_elevol_mute( 0 ) ;
}
setMsgColor( recMesId[1], EXE_COLOR ) ;
sndPlay() ;
setMsgColor( recMesId[1], MOJI_COLOR ) ;
SND_elevol_mute( s ) ;
lev = 0 ;
}
return NOERR ;
}
/* アンドゥ */
int recUndo(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
setMsgColor( recMesId[2], EXE_COLOR ) ;
unDo() ;
setMsgColor( recMesId[2], MOJI_COLOR ) ;
MMI_FlushEvnt() ; /* イベントをフラッシュ */
return NOERR ;
}
/* 各種ボリュームの設定 */
int recVolumeSet(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
int var, min, max, len, page, s ;
int var2, min2, max2, delta2, ptColumn2 ;
MMI_SendMessage( kobj, MM_GETSCROLL, 5,
&var, &min, &max, &len, &page ) ;
if( kobj == recLineVolumeId ) /* ライン入力 */
{
MMI_SendMessage( recLineNumId, MM_GETNUMBOX, 5,
&var2, &min2, &max2, &delta2, &ptColumn2 ) ;
MMI_SendMessage( recLineNumId, MM_SETNUMBOX, 5,
var, min2, max2, delta2, ptColumn2 ) ;
MMI_SendMessage( recLineNumId, MM_SHOW, 0 ) ;
SND_elevol_set( 0, var, var ); /* line volume set */
if( var == 0 )
{
SND_get_elevol_mute( &s ) ;
SND_elevol_mute( s & 0xfffffff3 ) ;
}
}
if( kobj == recCdVolumeId ) /* CD */
{
MMI_SendMessage( recCdNumId, MM_GETNUMBOX, 5,
&var2, &min2, &max2, &delta2, &ptColumn2 ) ;
MMI_SendMessage( recCdNumId, MM_SETNUMBOX, 5,
var, min2, max2, delta2, ptColumn2 ) ;
MMI_SendMessage( recCdNumId, MM_SHOW, 0 ) ;
SND_elevol_set( 1, var, var ); /* cd volume set */
if( var == 0 )
{
SND_get_elevol_mute( &s ) ;
SND_elevol_mute( s & 0xffffffcf ) ;
}
}
if( kobj == recMicVolumeId ) /* マイク */
{
MMI_SendMessage( recMicNumId, MM_GETNUMBOX, 5,
&var2, &min2, &max2, &delta2, &ptColumn2 ) ;
MMI_SendMessage( recMicNumId, MM_SETNUMBOX, 5,
var, min2, max2, delta2, ptColumn2 ) ;
MMI_SendMessage( recMicNumId, MM_SHOW, 0 ) ;
SND_elevol_set( 2, var, var ); /* mic volume set */
if( var == 0 )
{
SND_get_elevol_mute( &s ) ;
SND_elevol_mute( s & 0xffffffbf ) ;
}
}
return NOERR ;
}
/* 録音時間 */
int recTimeSet(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
return NOERR ;
}
/* サンプリングレート */
int recRateSet(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
int timeMax ;
int var, min, max, delta, ptColumn ;
/* サンプリングレートから録音時間の最大値を随時設定 */
MMI_SendMessage( recRateNumId, MM_GETNUMBOX, 5,
&var, &min, &max, &delta, &ptColumn ) ;
timeMax = ( sndBufSize - 32 ) / var * 10 ;
MMI_SendMessage( recTimeNumId, MM_GETNUMBOX, 5,
&var, &min, &max, &delta, &ptColumn ) ;
max = timeMax ;
if( var > max )
var = max ;
MMI_SendMessage( recTimeNumId, MM_SETNUMBOX, 5,
var, min, max, delta, ptColumn ) ;
MMI_SendMessage( recTimeNumId, MM_SHOW, 0 ) ;
return NOERR ;
}